/**
 * 获取地址信息列表
 * @param query
 */
function getPlaceData(query) {
    $('#PlaceList')
        .DataTable(
            {
                "destroy": true,
                // "searching":false,
                "pagingType": "full_numbers",
                "sLoadingRecords": "正在加载数据...",
                "sZeroRecords": "暂无数据",
                "ajax": {
                    url: "/place/getPlaceList",
                    // dataSrc: 'data',//原来为空，修改为data 因为服务端模式返回的是data入参
                    dataSrc: "",
                    type:"post",
                    data : query,
                },
                // "serverSide": true,//服务端分页
                // "lengthChange": false,//是否允许用户自定义显示数量
                // "scrollY": "360px",//竖向滚动条
                // "scrollCollapse": "true",//是否出现滚动条
                // 'iDisplayLength':10,
                "searching": true,
                "columns": [
                    {
                        "data": "id"
                    },
                    {
                        "data": "name"
                    },
                    {
                        "data": "sex"
                    },
                    {
                        "data": "createTime"
                    },
                    {
                        "data": "updateTime"
                    },
                    {
                        "data": null,
                        "render": function (data, type, row, meta) {
                            var html = "<a  href='#' role='button' data-toggle='modal' class='btn btn-success btn-xs btn-green' onclick='function1("
                                + JSON.stringify(row)
                                + ")'><i class='fa fa-pencil' ></i>操作1</a>    "
                                + '<a href="#" role="button" data-toggle="modal" class=\'btn btn-danger btn-xs btn-remove\' onclick="function2('
                                + row.id
                                + ')"><i class="fa fa-trash-o"  ></i>操作2</a>  ';
                            return html;
                        }
                    }
                ],
                "language": {
                    "processing": "玩命加载中...",
                    "lengthMenu": "显示 _MENU_ 项结果",
                    "zeroRecords": "没有匹配结果",
                    "info": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                    "infoEmpty": "显示第 0 至 0 项结果，共 0 项",
                    "infoFiltered": "(由 _MAX_ 项结果过滤)",
                    "infoPostFix": "",
                    "url": "",
                    "paginate": {
                        "first": "首页",
                        "previous": "前一页",
                        "next": "下一页",
                        "last": "末页"
                    }
                }
            });
}


/**
 * 刷新
 */
function refreshPlaceData(){
    var b={
        "id":$('#searchPlaceId').val() !="" ? $("#searchPlaceId").val():0,
        'name':$('#searchPlaceName').val(),
        'sex':$('#searchPlaceSex').val(),
        // "limit":1,
        // "page":1
    };
    $.ajax({
        // 请求方式
        type: "post",
        // 请求地址
        url: "/place/getPlaceList",
        data: JSON.stringify(b),
        contentType: 'application/json;charset=UTF-8',
        // 请求成功
        success: function (result) {
            b.recordsTotal=result;
            getPlaceData(b);

        },
        // 请求失败，包含具体的错误信息
        error: function (e) {
            console.log(e.status);
            console.log(e.responseText);
            alert("操作有误请联系管理员")
        }
    });

}
